package com.yuer.resumer.service.impl;

import com.yuer.edu.Resume;
import com.yuer.resumer.dao.ResumerDao;
import com.yuer.resumer.service.ResumerService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class ResumerServiceImpl  implements ResumerService {

    @Autowired
    ResumerDao resumerDao;

    @Override
    public Resume findDefaultResumeByUserId(Long userId) {
        Resume resume = new Resume();
        try {
            resume.setUserId(userId);
            resume.setIsDefault(1);

            Optional<Resume> optional = resumerDao.findOne(Example.of(resume));
            Resume result = optional.isPresent() ? optional.get(): null;
            return result;
        } catch (Exception e) {
            System.err.println("出现异常啦" + e.getMessage());
        }
        return resume;
    }
}
